<template>
  <div class="app-container">

    <!-- 查询和其他操作 -->
    <div class="filter-container tit">
       <div>核销列表</div>
      <el-button v-permission="['GET /admin/wx/wxWriteOff']" :loading="downloadLoading"  class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">核销</el-button>
    </div>

    <!-- 查询结果 -->
    <el-table v-loading="listLoading" :data="list" element-loading-text="正在查询中。。。" border fit highlight-current-row>

      <el-table-column align="center" label="订单编号" prop="goodsSn" />
      <el-table-column align="center" label="商品图片" prop="picUrl">
            <template slot-scope="scope">
                <img :src="scope.row.picUrl" width="40" />
            </template>
      </el-table-column>
      <el-table-column align="center" label="商品名称" prop="goodsName" />

      <el-table-column align="center" label="金额" prop="price" />

      <el-table-column align="center" label="核销时间" prop="writeOffTime" />

    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />


  </div>
</template>
<style scoped>
  .tit{
      display: flex;
      justify-content: space-between;
      align-items: center;
  }
</style>
<script>
import { listWrite } from '@/api/comment'
import { replyComment } from '@/api/order'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination

export default {
  name: 'Comment',
  components: { Pagination },
  data() {
    return {
      list: [],
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 20,
        userId: undefined,
        valueId: undefined,
        sort: 'add_time',
        order: 'desc'
      },
      downloadLoading: false,
      replyForm: {
        commentId: 0,
        content: ''
      },
      replyFormVisible: false
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      listWrite(this.listQuery).then(response => {
        this.list = response.data.data.list
        this.total = response.data.data.total
        this.listLoading = false
      }).catch(() => {
        this.list = []
        this.total = 0
        this.listLoading = false
      })
    },
    reply() {
      replyComment(this.replyForm).then(response => {
        this.replyFormVisible = false
        this.$notify.success({
          title: '成功',
          message: '回复成功'
        })
      }).catch(response => {
        this.$notify.error({
          title: '失败',
          message: response.data.errmsg
        })
      })
    },
    handleDownload() {
      this.$router.push({
          path:"/goods/writedet"
      })
    }
  }
}
</script>
